// banner图接口管理
import request from "@/utils/request";
import type {
  BannerEditResponse,
  BannerPageRequest,
  BannerPageResponse,
  BannerResponse,
  BannerType,
} from "./types";

enum API {
  BANNER_PAGE = "/wx/banner/page",
  BANNER_CREATE_OR_EDIT = "/wx/banner/createOrEdit",
  BANNER_GET_BY_ID = "/wx/banner//getById",
  BANNER_REMOVE = "/wx/banner/remove",
  BANNER_CHANGE_STATUS = "/wx/banner/changeStatus",
}

export const bannerPage = (data: BannerPageRequest) =>
  request.post<any, BannerPageResponse>(API.BANNER_PAGE, data);

export const bannerCreateOrEdit = (data: BannerType) =>
  request.post<any, BannerEditResponse>(API.BANNER_CREATE_OR_EDIT, data);

export const bannerGetById = (id: number) =>
  request.get<any, BannerResponse>(API.BANNER_GET_BY_ID + `/${id}`);

export const bannerRemove = (id: number) =>
  request.delete<any, BannerEditResponse>(API.BANNER_REMOVE + `/${id}`);

export const bannerChangeStatus = (id: number, status: number) =>
  request.post<any, BannerEditResponse>(
    API.BANNER_CHANGE_STATUS + `/${id}` + `/${status}`
  );
